﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using Core.Module.Interfaces.Model;
using Core.Module.Interfaces.Controller;
using Core.Module.Interfaces;

namespace Module.MultiSiteFields.Controls.NodeBrowser
{
    public class Editor:UserControl
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            RenderEditScript();
        }

        private void RenderEditScript()
        {
            IModuleNode node = ObjectManager.Resolve<INodeController<IBackOffice>>().Get(Request["id"]);
            
            System.Web.UI.HtmlControls.HtmlGenericControl script = new System.Web.UI.HtmlControls.HtmlGenericControl("script");
            script.Attributes.Add("type", "text/javascript");
            script.InnerHtml = "jQuery('#" + Parent.ClientID + "').NodeBrowser({id:'" + node.Id + "'});";
            this.Controls.Add(script);
        }
    }
}
